<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2020/8/25
  Time: 14:28
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="${basePath}static/js/jquery-1.4.2.min.js"></script>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="_linkPages/basePath.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>二手市场首页</title>
    <link rel="stylesheet" type="text/css" href="static/css/style.css" />
    <link rel="stylesheet" type="text/css" href="static/css/shopping-mall-index.css" />
    <script type="text/javascript" src="static/js/jquery.js"></script>
    <script type="text/javascript" src="static/js/zhonglin.js"></script>
    <script type="text/javascript" src="static/js/zhongling2.js"></script>

</head>

<body>
<!--header-->
<%@ include file="index_linkPages/header.jsp"%>

<!--广告栏-->
<div class="advertisement w1200">
    <p style="text-align:center;font-size:15px;color:#000;line-height:74px;"></p>
</div>

<!--内容页面-->
<div class="shopping-content w1200">
    <div class="sp-con-info">
        <ul class="sp-info-r m-act beaut">
            <c:forEach items="${commodities}" var="commodity">
            <li style="border-bottom:0; border-right:0;">
                <div class="li-top">
                    <input type="hidden" name="id" id="id" value="${commodity.id}"/>
                    <a href="#" class="li-top-tu"><img src="${basePath}commodityDp?method=showPic&pic=${commodity.pic}" /></a>
                    <p class="jiage"><span class="sp1">￥${commodity.price}</span>/${commodity.unit}</p>
                </div>
                <p class="miaoshu">${commodity.commName}</p>
                <div class="li-md">
                    <div class="md-l f-l">
<%--                        <input class="md-l-l f-l" ap="" name="number${commodity.id}" id="number${commodity.id}" value="1" />--%>
                        <div class="md-l-r f-l">
                            <button class="md-xx" ab="" id='down' onclick="prev3('${commodity.id}');">-</button>
                        </div>
                        <input class="md-l-l f-l" ap="" name="number${commodity.id}" id="${commodity.id}" value="1" />
                        <div class="md-l-r f-l">
                            <button class="md-xs" at="" id='add' onclick="next3('${commodity.id}');">+</button>
                        </div>
                        <div style="clear:both;"></div>
                    </div>
                    <div class="md-r f-l">
                        <button class="md-l-btn1" onclick="toPay('${commodity.id}')">立即购买</button>
                        <button class="md-l-btn2" onclick="toShoppCart('${commodity.id}')">加入购物车</button>
                    </div>
                    <div style="clear:both;"></div>
                </div>
                <p class="pingjia">${commodity.commInform}</p>
                <p class="weike">${commodity.businessName}</p>
            </li>
            </c:forEach>
            <div style="clear:both;"></div>
        </ul>

        <!--分页-->
        <div class="paging">
            <div class="pag-left f-l">
                <c:if var="isFirst" test="${pm.pn <= 1}">
                    <a href="javascript:;" class="about left-r f-l"><</a>
                </c:if>
                <c:if test="${!isFirst}">
                    <a href="${basePath}commodityDp?method=toErshoushichang&pn=${pm.pn-1}" class="about left-r f-l"><</a>
                </c:if>
                <ul class="left-m f-l">
                    <c:forEach var="i" begin="1" end="${pm.pages}" step="1">
                        <c:if var="isPn" test="${pm.pn==i}">
                            <li class="active"><a href="javascript:;">${i}</a></li>
                        </c:if>
                        <c:if test="${!isPn}">
                            <li><a href="${basePath}commodityDp?method=toErshoushichang&pn=${i}">${i}</a></li>
                        </c:if>
                    </c:forEach>
                    <div style="clear:both;"></div>
                </ul>
                <c:if var="isLast" test="${pm.pn >= pm.pages}">
                    <a href="javascript:;" class="about left-l f-l">></a>
                </c:if>
                <c:if test="${!isLast}">
                    <a href="${basePath}commodityDp?method=toErshoushichang&pn=${pm.pn+1}" class="about left-l f-l">></a>
                </c:if>
                <div style="clear:both;"></div>
            </div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <div class="pag-right f-l">
                <div class="jump-page f-l">
                    到第<input type="text" name="page" id="page"/>页
                </div>
                <button class="f-l" onclick="toCanyinyule()">确定</button>
                <div style="clear:both;"></div>
            </div>
            <div style="xclear:both;"></div>
        </div>
        <script>
            function toCanyinyule() {
                let page = document.getElementById("page").value;
                window.location.href = "${basePath}commodityDp?method=toErshoushichang&pn="+(page>=${pm.pages}?${pm.pages}:page);
            }
            function toPay(id) {
                let number = document.getElementById(id).value;
                window.location.href = "${basePath}purchase?method=toPay&id="+id+",${sessionScope.user.username},"+number;
            }
            function toShoppCart(id) {
                let number = document.getElementById(id).value;
                window.location.href = "${basePath}purchase?method=toShoppCart&id="+id+",${sessionScope.user.username},"+number;
            }


        </script>
    </div>
</div>

<!--底部一块-->
<%@ include file="index_linkPages/footer.jsp"%>

<%@ include file="index_linkPages/right.jsp"%>

<script>
        function prev3(id) {

            let count = document.getElementById(id);
            let countValue = parseInt(count.value);

            if (countValue > 1) {
                count.value = countValue - 1;
            } else {
                count.value = countValue;
            }


        }
        
        function next3(id) {

            let count = document.getElementById(id);
            let countValue = parseInt(count.value);



            count.value = countValue + 1;

        }

</script>

</body

</html>

